import {RoutesMenu} from "./routes-menu"

/**
 * 非登录类路由
 */
export const StaticRoutes = [
  {
    path: "/login",
    name: "login",
    component: () => import('../views/login.vue'),
    meta: {title: "登录", showTitle: false}
  },
]
/**
 * 登录类路由-将路由菜单转换成路由
 */
export const MenuRoutes = getRootPath(RoutesMenu)

//将所有AsyncRoutesMenu数据转为根路由的数组，
//这样使用layouts下的index.vue的一个router-view就可以加载AsyncRoutesMenu菜单下的路由
function getRootPath(list) {
  let rootPathList = []
  for (let i = 0; i < list.length; i++) {
    rootPathList = [...rootPathList, {...list[i], children: null}]
    if (list[i].children) rootPathList = [...rootPathList, ...getRootPath(list[i].children)]
  }
  return rootPathList
}
